﻿// Copyright (c) Inossem. All rights reserved.
// Licensed under the LGPL-3.0 license. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using WPFLocalizeExtension.Engine;
using WPFLocalizeExtension.Extensions;

namespace DWF.Studio.Custom
{
    public static class LocalizationProvider
    {
        public static string GetLocalizedString(string key)
        {
            var result = key;
            if (LocalizeDictionary.Instance.ResourceKeyExists(Assembly.GetExecutingAssembly().GetName().Name, "codelangdic", key, LocalizeDictionary.Instance.Culture))
            {
                result = LocalizeDictionary.Instance.GetLocalizedObject(Assembly.GetExecutingAssembly().GetName().Name, "codelangdic", key, LocalizeDictionary.Instance.Culture)?.ToString();
            }

            return result;
        }

        public static async Task<string> GetLocalizedStringAsync(string key)
        {
            string result = null;
            await Task.Run(() => { result = GetLocalizedString(key); });

            return result;
        }
    }
}
